package com.ljy.my_study.lintcode.top_k;

import java.util.Arrays;

/** 
* @author James
* @date 2018年10月11日 
*/
public class TestMain {
	public static void main(String[] args) {
		int[] nums= {2,8,4,32,25,1,6,17,43};
		System.out.println(partion(nums,0,nums.length-1));
		System.out.println(Arrays.toString(nums));
	}
	
	public static int partion(int[] array, int low, int high) {

        int mid = array[low];
        while (low < high) {
            while (low < high && array[high] >= mid)
                high--;
            array[low] = array[high];
            while (low < high && array[low] <= mid)
                low++;
            array[high] = array[low];
        }
        array[low] = mid;
        return low;
    }

}
